import {posts} from '../assets/server/https'
import {get, post} from '../assets/server/http'

// 获取全局设置
export function getGlobalSetting (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/manage/setting`
  return get(url, param)
}

// 设置全局设置
export function setGlobalSetting (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/manage/setting`
  return posts(url, param)
}

// 获取文章的标签列表
export function getLabelList (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/label/tree`
  return get(url, param)
}

// 取消文章的发布
export function revokeArticle (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/publish/revoke${param}`
  return posts(url, param)
}

// 删除文章
export function delArticle (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/manage/delete${param}`
  return posts(url)
}

// 保存文章的排序
export function saveArticleSort (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/manage/ordinal`
  return posts(url, param)
}

// 发布文章
export function publishArticle (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/publish/${param}`
  return posts(url)
}

// 删除标签
export function delLabel (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/label/delete/${param.labelId}`
  delete param.labelId
  return post(url, param)
}

// 文章的保存并发布
export function saveAndPublish (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/manage/saveAndPublish?wxAppid=${param.wxAppid}`
  delete param.wxAppid
  return posts(url, param)
}

// 获取标签的详情
export function getLabelDetail (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/label/${param.labelId}`
  delete param.labelId
  return get(url, param)
}

// 修改标签信息
export function updateLabelInfo (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/label/update?wxAppid=${param.wxAppid}`
  delete param.wxAppid
  return posts(url, param)
}

// 添加标签
export function addLabelTag (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/label/add?wxAppid=${sessionStorage.getItem('appid')}`
  return posts(url, param)
}

// 单个删除FAQ
export function delSingleFAQ (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/delete/${param.qaId}`
  return posts(url)
}

// 批量删除FAQ
export function delFAQ (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/delete?${param}`
  return posts(url)
}

// 获取FQA详情
export function getFAQDetail (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/details`
  return get(url, param)
}

// 获取FAQ列表
export function getFAQList (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/list`
  return get(url, param)
}

// 修改FAQ信息
export function updateFAQ (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/update`
  return posts(url, param)
}

// 添加FAQ
export function addFAQ (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/qa/create`
  return posts(url, param)
}

// 添加文章
export function addArticle (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/manage/add?wxAppid=${param.wxAppid}`
  delete param.wxAppid
  return posts(url, param)
}

// 修改文章信息
export function updateArticle (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/manage/update`
  return posts(url, param)
}

// 获取文章详情
export function getArtiDetail (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/article/manage/details`
  return get(url, param)
}

// 文章置顶
export function articleUp (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/manage/up`
  return post(url, param)
}

// 取消置顶
export function articleCancelUp (param) {
  let url = `${process.env.VUE_APP_SERVICE_KNOWLEDGE}/manage/cancelUp`
  return post(url, param)
}
